package com.heima.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.admin.mapper.AdChannelLabelMapper;
import com.heima.admin.service.AdChannelLabelService;
import com.heima.apis.wemedia.IChannelClient;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.admin.pojos.AdChannelLabel;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.model.wemedia.pojos.WmNews;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 * 频道标签信息表 服务实现类
 * </p>
 *
 * @author 李海鹏
 */
@Slf4j
@Service
@Transactional
public class AdChannelLabelServiceImpl extends ServiceImpl<AdChannelLabelMapper, AdChannelLabel> implements AdChannelLabelService {

    @Resource
    private IChannelClient channelClient;

    /**
     * 新增一个频道
     * @param wmChannel
     * @return
     */
    @Override
    public ResponseResult saveChannel(WmChannel wmChannel) {
        return channelClient.save(wmChannel);
    }

    /**
     * 频道的分页模糊查询
     *
     * @param dto
     * @return
     */
    @Override
    public ResponseResult listChannel(ChannelDto dto) {

        log.info("service接受到的数据为————————{}",dto.getPage() + "   " + dto.getSize());

        return channelClient.page(dto);
    }

    /**
     * 对channel表的修改
     *
     * @param dto
     * @return
     */
    @Override
    public ResponseResult updateChannel(WmChannel dto) {
        return channelClient.update(dto);
    }

    /**
     * 对频道的删除
     *
     * @param id
     * @return
     */
    @Override
    public ResponseResult delChannel(Integer id) {

        log.info("service 拿到的id为{}",id);
        return channelClient.del(id);
    }
}
